<?php
require_once("../../../config.inc.php");
require_once("../../../app/_inc/include.php");

$objUser = $_SESSION[USEROBJ];
$errMsg = sxREQ('msg');

if(!isset($_REQUEST["mod"])){
	$url = $_SESSION[USEROBJ]->getHistory(-1, true)."&msg=".urlencode(_t("variabile 'mod' non passata")); 
	serverRedir($url);
}
if(!isset($_REQUEST["menu_page"])){
	$url = $_SESSION[USEROBJ]->getHistory(-1, true)."&msg=".urlencode(_t("variabile 'menu_page' non passata")); 
	serverRedir($url);
}
$module = sxREQ("mod");
$menuPage = sxREQ("menu_page");
$sSQL = "SELECT mg.*, m.description AS mdes, mp.description AS pdes
		FROM menu_page mp
		INNER JOIN module m ON m.module=mp.module 
		LEFT JOIN menu_group mg ON m.module=mg.module  AND mg.menu_page = '$menuPage'
		WHERE mp.module='$module' AND mp.menu_page = '$menuPage'
		ORDER BY mg.sequence, mg.menu_group";
$query = $objSDAO->query($sSQL, "mg");
$row = $objSDAO->fetch("mg");
//output HTML
$aOpz = array("tit2"=>_t("Lista dei gruppi voci di pagina menu"));
echo(headerHTML($aOpz));
echo(bodyHTML($aOpz));
//output comandi
$aCmd = array("ins"=>array("pag"=>"menuPageGroupIns.php?mod=$module&menu_page=$menuPage",
										"title"=>_t("Inserisce un nuovo gruppo voci di pagina men@"),
										"text"=>_t("nuovo gruppo"),
										"perm"=>"newmenu"),
					"back"=>array("pag"=>$objUser->getHistory(-1,false),
										"title"=>$objUser->getHistoryText(-1),
										"text"=>$objUser->getHistoryText(-1),
										"perm"=>"")
					);
echo(commandsHTML($aCmd));	
//output dei dati
echo("<table class='tabl01' width=\"100%\" cellpadding=\"3\" cellspacing=\"2\">\n");
echo("<tr>" .
		"<td class=\"titl01\"colspan=\"7\">".
			_t("Modulo").": '<a class=\"titl01\" href=\"moduleView.php?mod=$module&xsn=".XSN."\">$module</a>' - ".
			$row["mdes"]." - "._t("Pagina menu:")." ".$menuPage." - ".$row["pdes"].
		"</td>" .
	"</tr>\n");
echo("<tr>" .
		"<td class=\"tabh01\" width=\"1%\">"._t('seq.')."</td>" .
		"<td class=\"tabh01\" width=\"1%\">"._t('gruppo')."</td>" .
		"<td class=\"tabh01\" width=\"40%\">"._t('description')."</td>" .
		"<td class=\"tabh01\" width=\"1%\">"._t('vis.')."</td>" .
		"<td class=\"tabh01\" width=\"57%\">"._t('note')."</td>" .
	"</tr>\n");	
$numElem = 0;
while($row){
	if (!empty($row['menu_page'])){ 
		$numElem ++;
		echo(
			"<tr>" .
				"<td class=\"text01\" valign='top' align ='right'>".$row["sequence"]."</td>" .
				"<td class=\"text01\" valign='top' align='center'><a class=\"text01\" ".
					goToPag("menuPageGroupView.php?mod=".$row["module"].
					"&menu_page=".$row["menu_page"]."&menu_group=".$row["menu_group"]."&xsn=".XSN).
					" title=\""._t("Visualizza gruppo voci pagina men@")."\">".
					$row["menu_group"]."</a></td>\n" .
				"<td class=\"text01\" valign='top'>".$row["description"]."</td>" .
				"<td class=\"text01\" valign='top'>".(($row["flag_display"]=='Y')?_t('yes'):_t('no'))."</td>" .
				"<td class=\"text01\" valign='top'><pre class='text01'>".$row["note"]."</pre></td>" .
			"</tr>\n");
	}
	$row = $objSDAO->fetch("mg");
}
if($numElem == 0) {
	echo("<tr>" .
			"<td class=\"text01\" colspan=\"7\">"._t("Non &egrave; presente alcun gruppo.")."</td>".
		"</tr>\n");
}
echo("</table>\n");
echo(commandsHTML($aCmd));
echo(footerHTML());
?>
		
?>
